home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / IRBIT1.DEM < prev    next >
Text File  |  1991-04-29  |  1KB  |  42 lines

  1. PROGRAM d7r10 (input,output);
  2. (* driver for routine IRBIT1 *)
  3. (* calculate distribution of runs of zeros *)
  4. CONST
  5.    nbin=15;
  6.    ntries=500;
  7. VAR
  8.    i,iflg,ipts,iseed,j,n : integer;
  9.    twoinv : real;
  10.    delay : ARRAY [1..nbin] OF real;
  11.  
  12. (*$I MODFILE.PAS *)
  13. (*$I IRBIT1.PAS *)
  14.  
  15. BEGIN
  16.    iseed := 1234;
  17.    FOR i := 1 to nbin DO BEGIN
  18.       delay[i] := 0.0
  19.    END;
  20.    writeln ('distribution of runs of n zeros');
  21.    writeln ('n':6,'probability':22,'expected':18);
  22.    ipts := 0;
  23.    FOR i := 1 to ntries DO BEGIN
  24.       IF (irbit1(iseed) = 1) THEN BEGIN
  25.          ipts := ipts+1;
  26.          iflg := 0;
  27.          FOR j := 1 to nbin DO BEGIN
  28.             IF ((irbit1(iseed) = 1) AND (iflg = 0))
  29.             THEN BEGIN
  30.                iflg := 1;
  31.                delay[j] := delay[j]+1.0
  32.             END
  33.          END
  34.       END
  35.    END;
  36.    twoinv := 0.5;
  37.    FOR n := 1 to nbin DO BEGIN
  38.       writeln ((n-1):6,(delay[n]/ipts):19:4,twoinv:20:4);
  39.       twoinv := twoinv/2.0
  40.    END
  41. END.
  42.